package com.jboost.modules.area.model;

import com.jboost.modules.area.entity.JboostArea;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
  * 树形列表用到
 */
@Data
public class JboostAreaTreeModel implements Serializable {

	private static final long serialVersionUID = 4013193970046502756L;

	/** ID */
	private String id;
	/**code*/
	private String code;
	/**pCode*/
	private String pCode;
	/**name*/
	private String name;
	/**short_name*/
	private String shortName;
	/**pinyin*/
	private String pinyin;
	/**short_pinyin*/
	private String shortPinyin;
	/**是否有子节点：*/
	private boolean hasChild  ;

	private Map<String,String> scopedSlots;

	public Map<String, String> getScopedSlots() {
		return scopedSlots;
	}

	public void setScopedSlots(Map<String, String> scopedSlots) {
		this.scopedSlots = scopedSlots;
	}



	private List<JboostAreaTreeModel> children;

	public List<JboostAreaTreeModel> getChildren() {
		return children;
	}

	public void setChildren(List<JboostAreaTreeModel> children) {
		this.children = children;
	}

	public JboostAreaTreeModel() {

	}

	public JboostAreaTreeModel(JboostArea area) {
		BeanUtils.copyProperties(area,this);
		if(area.getHasChild()) {
			this.children = new ArrayList<JboostAreaTreeModel>();
		}
	}
	public boolean getHasChild(){
		return "00".equals(this.code.substring(this.code.length()-2));
	}


}
